package com.cyam.util;

import java.io.Serializable;
import java.util.List;

public class Pager implements Serializable{

	private static final long serialVersionUID = -1517114146113942561L;

	/** 每页记录数 */
	private int pageSize;
	/** 页号 */
	private int pageNum;
	/** 总页数 */
	private int totalPages;
	/** 记录数 */
	private int totalCount;
	/** 数据对象 */
	@SuppressWarnings("rawtypes")
	private List item;

	/**
	 * 无参数构造器
	 */
	public Pager() {

	}

	/**
	 * 构造器
	 * 
	 * @param pageSize
	 *            每页记录数
	 * @param pageNum
	 *            页号
	 * @param totalPages
	 *            总页数
	 * @param item
	 *            数据对象
	 */
	public Pager(int pageSize, int pageNum, int totalCount, @SuppressWarnings("rawtypes") List item) {
		this.pageSize = pageSize;
		this.pageNum = pageNum;
		this.totalCount = totalCount;
		this.item = item;
		if (totalCount > 0) {
			this.totalPages = totalCount/pageSize;
			if (totalCount%pageSize != 0) {
				this.totalPages++;
			}
		} else {
			this.totalPages = 0;
		}
	}
	
	
	
	
	public Pager(int pageSize, int pageNum,int totalCount) {
		this(pageSize, pageNum, totalCount, null);
	}

	/**
	 * 获取每页记录数
	 */
	public int getPageSize() {
		return pageSize;
	}

	/**
	 * 设置每页记录数
	 */
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	/**
	 * 获取页号
	 */
	public int getpageNum() {
		return pageNum;
	}

	/**
	 * 设置页号
	 */
	public void setpageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	/**
	 * 获取总页数
	 */
	public int gettotalPages() {
		return totalPages;
	}

	/**
	 * 设置总页数
	 */
	public void settotalPages(int totalPages) {
		this.totalPages = totalPages;
	}

	/**
	 * 获取数据对象
	 */
	@SuppressWarnings("rawtypes")
	public List getItem() {
		return item;
	}

	/**
	 * 设置数据对象
	 */
	public void setItem(@SuppressWarnings("rawtypes") List item) {
		this.item = item;
	}

	/**
	 * 设置记录数 
	 */
	public int gettotalCount() {
		return totalCount;
	}

	/**
	 * 设置记录数 
	 */
	public void settotalCount(int totalCount) {
		this.totalCount = totalCount;
	}
}
